package org.shoukaiseki.test.testhttpclient;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.LinkedHashMap;

@Controller
public class IndexController {

    @GetMapping(value = "/")
    @ResponseBody
    public String indexGet(String a, String b, HttpServletResponse response) throws JsonProcessingException {
        HashMap<Object, Object> map = new LinkedHashMap<>();
        map.put("a",a);
        map.put("b",b);
        map.put("java.version",System.getProperty("java.version"));
        map.put("java.properties",System.getProperties());
        ObjectMapper mapper = new ObjectMapper();
        StringBuffer sb = new StringBuffer();
        sb.append("<pre  style='font-size:16px'>");
        sb.append(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map));
        sb.append("</pre>");
        return sb.toString();
    }
}

